#coding: UTF-8

import numpy as np
from math import *


#给个真值，给个预测概率，然后算出来个数
def logloss(true_label, predicted, eps=1e-15):
    p = np.clip(predicted, eps, 1 - eps)
    if true_label == 1:
        if p <= 0:
            p = eps
        return -log(p)
    else:
        if p >= 1.0:
            p = 1 - eps
        return -log(1 - p)